<template>
  <basic-dialog
    width="50%"
    title="批量设置加价率"
    :visible="visible"
    :handleClose="handleClose"
    :handleOk="handleOk"
  >
    <el-form label-position="right" label-width="120px">
      <el-form-item
        v-for="item in formItems"
        :key="item.prop"
        :label="item.label"
      >
        <el-input-number
          v-model="formData[item.prop]"
          size="mini"
          :controls=false
          :max="item.max"
          :min="item.min"
          :precision="2"
        />
      </el-form-item>
    </el-form>
  </basic-dialog>
</template>
<script>
import BasicDialog from '@/components/BasicDialog';
export default {
  components: { BasicDialog },
  props: {
    visible: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      formItems: [
        { label: '指导加价率', prop: 'guideAddRate', max: 10, min: 0 },
        { label: '畅销指导加价率', prop: 'sellWellAddRate' },
        { label: '底线加价率', prop: 'limitAddRate' },
      ],
      formData: {}
    }
  },
  methods: {
    handleClose () {
      this.$emit('update:visible', false)
    },
    handleOk () {
      this.$emit('getRates', this.formData)
      this.$emit('update:visible', false)
      this.formData = {}
    }
  }
}
</script>
